package com.baymax.study.base.infrastructure.configs;

import com.baymax.study.base.infrastructure.filters.MyRequestContextFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;

/**
 * FilterRegesConfiguration
 *
 * @author Baymax
 * @since 2024-07-22
 */
@Configuration
public class FilterRegisterConfiguration {
    @Bean
    public FilterRegistrationBean<MyRequestContextFilter> myRequestFilter(
        MyRequestContextFilter myRequestContextFilter) {
        FilterRegistrationBean<MyRequestContextFilter> myRequestFilter = new FilterRegistrationBean<>();
        myRequestFilter.setFilter(myRequestContextFilter);
        myRequestFilter.setUrlPatterns(Collections.singletonList("/*"));
        return myRequestFilter;
    }
}
